package net.qiqbframework.messaging.annotation;

import javax.annotation.Nonnull;
import java.lang.reflect.Executable;
import java.util.Optional;

/**
 * 消息处理工厂
 */
public interface MessageHandlingMemberFactory {


    default <T> Optional<MessageExecutableHandler> createHandler(@Nonnull Class<T> declaringType,
                                                                 @Nonnull Executable executable,
                                                                 @Nonnull HandlerParameterResolverFactory parameterResolverFactory) {
        return createHandler(declaringType, executable, parameterResolverFactory, HandlerAttributesPostProcessor.EMPTY);
    }

    /**
     * 根据 executable 创建一个合适消息处理对象
     */
    <T> Optional<MessageExecutableHandler> createHandler(@Nonnull Class<T> declaringType,
                                                         @Nonnull Executable executable,
                                                         @Nonnull HandlerParameterResolverFactory parameterResolverFactory
            , @Nonnull HandlerAttributesPostProcessor handlerAttributesPostProcessor);
}
